<%--
  Created by IntelliJ IDEA.
  User: gg
  Date: 14-4-23
  Time: 下午3:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title></title>
</head>
<body>
<div class="row">
<div class="col-xs-12">
    <div class="page-header no-padding">
        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons ">
            <button class="btn btn-xs btn-primary add_button">
                <i class="icon-zoom-in bigger-130"></i>
                      添加
            </button>
            <button class="btn btn-xs btn-danger delete_button">
                <i class="icon-trash bigger-130"></i>
                      删除
            </button>
        </div>
    </div><!-- /.page-header -->

<div class="table-responsive">
<table id="pRole_table" class="table table-striped table-bordered table-hover table-condensed" url="${ctx}/pRole/index.do">
<thead>
<tr>
    <th class="center">
        <label>
            <input type="checkbox" class="ace" />
            <span class="lbl"></span>
        </label>
    </th>
    <th>角色名称</th>
    <th>创建人</th>
    <th>创建时间</th>
    <th>更新人</th>
    <th>更新时间</th>
    <th>操作</th>
</tr>
</thead>
<tbody>
<c:forEach items="${list}" var="bean" varStatus="status">
    <tr>
        <td class="center">
            <label>
                <input type="checkbox" class="ace" name="id" value="${bean.id}"/>
                <span class="lbl"></span>
            </label>
        </td>
        <td><a href="#">${bean.name}</a></td>
        <td> ${bean.createTime}</td>
        <td> ${bean.createUser}</td>
        <td> ${bean.updateTime}</td>
        <td> ${bean.updateUser}</td>
        <td>
            <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">

                <a class="blue view_button" href="#">
                    <i class="icon-check bigger-130"></i>
                </a>

                <a class="green edit_button" href="#">
                    <i class="icon-pencil bigger-130"></i>
                </a>

                <a class="red delete_one_button" href="#">
                    <i class="icon-trash bigger-130"></i>
                </a>
            </div>
        </td>
    </tr>
</c:forEach>
</tbody>
</table>
</div><!-- /.table-responsive -->
<jsp:include page="../../page.jsp"></jsp:include>
</div><!-- /span -->
</div><!-- /row -->
<script type="text/javascript">
    $(function(){
    })
    var tableObj=$('#pRole_table');

    //add
    $('body').on('click', '.add_button', function (e) {
        window.location.href='${ctx}/pRole/add.do';
        e.stopPropagation();
        return false;
    })

    //edit
    $('body').on('click', '.edit_button', function (e) {
        var id = $(this).parents('tr').find('input[name=id]').val();
        var urlParams ='?id='+id;
        window.location.href='${ctx}/pRole/edit.do'+urlParams;
        e.stopPropagation();
        return false;
    })

    //view
    $('body').on('click', '.view_button', function (e) {
        var id = $(this).parents('tr').find('input[name=id]').val();
        var urlParams ='?id='+id;
        window.location.href='${ctx}/pRole/view.do'+urlParams;
        e.stopPropagation();
        return false;
    })

    //delete
    $('body').on('click', '.delete_button', function (e) {
        var idArray = tableObj.getTableSelectedIds();
        if (idArray.length == 0) {
            $.initAlert({message: '请至少选择一条记录'});
            return false;
        }
        $.initConfirm("你确定要删除选中的记录吗？", function (c) {
            if (c) {
                $.simpleAjax({url: '${ctx}/pRole/delete.do', data: {ids: idArray.join(',')}, callback: function (data) {
                    $.initAlert({message: data.message,callback:function(){
                        window.location.href='${ctx}/pRole/index.do';
                    }})
                }});
            }
        })
        e.stopPropagation();
        return false;
    })

    //delete
    $('body').on('click', '.delete_one_button', function (e) {
        var id = $(this).parents('tr').find('input[name=id]').val();
        $.initConfirm("你确定要删除选中的记录吗？", function (c) {
            if (c) {
                $.simpleAjax({url: '${ctx}/pRole/delete.do', data: {ids: id}, callback: function (data) {
                    $.initAlert({message: data.message,callback:function(){
                        window.location.href='${ctx}/pRole/index.do';
                    }})
                }});
            }
        })
        e.stopPropagation();
        return false;
    })
</script>
</body>
</html>